package com.shuo.dsa.niuke;

/**
 * Created by shuoGG on 2018/10/18 0018
 */
public class JumpFloor1 {
    public int JumpFloorRecur(int target) {
        if (target <= 1) return target;
        if (target == 2) return 2;
        return JumpFloorRecur(target - 1) + JumpFloorRecur(target - 2);
    }

    public int JumpFloor(int target) {
        if (target <= 1) return target;
        if (target == 2) return 2;
        int prepre = 1;
        int pre = 2;
        int cur = 3;
        for (int i = 3; i <= target; i++) {
            cur = pre + prepre;
            prepre = pre;
            pre = cur;
        }
        return cur;
    }
}
